package com.zhao.demo.unbound.demo03_source.sample05_fromelements

import com.zhao.entity.Student
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment


/**
 * Description: <br/>
 * Copyright (c) ，2020 ， 赵 <br/>
 * This program is protected by copyright laws. <br/>
 * Date： 2020/11/28 14:55
 *
 * @author 柒柒
 * @version : 1.0
 */

object FromElementsDemo {
  def main(args: Array[String]): Unit = {
    //1.环境准备
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    //隐式转换
    import org.apache.flink.api.scala._

    //a)基础数据类型
    env.fromElements(56.48,90.34,66.66)
      .filter(_ >= 60)
      .print("及格的学生->")

    env.fromElements(("张三",56.48),("李四",90.34),("王五",66.66))
      .filter(_._2 < 60)
      .print("不及格的学生->")

    env.fromElements(
      new Student("张三",56.64),
      new Student("李四",90.34),
      new Student("王五",66.66)
    ).filter(perEle =>perEle.getScore > 60 && perEle.getScore <100)
      .print("分数介于[60,100]的人->")

    //使用Lombok框架简化POJO
    env.fromElements(
      LittleStudent("张三",56.48),
      LittleStudent("李四",90.34),
      LittleStudent("王五",66.66)
    ).filter(_.Score > 60)
      .print("Lombok架构分数大于60->")

    env.execute()
  }
}
